<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="./css/index.css">
  <title>Document</title>
  <style>
    #main {
      width: 1000px;
      height: 800px;
      margin: auto;
    }
  </style>
</head>

<body>
  <div id="app">
      <div class="container">
        <div id="main"></div>
        <div class="button_fa">
            <button class="d-button mr-20" @click="downloadPdf">下载PDF</button>
            <button class="d-button danger" @click="close">关闭页面</button>
        </div>
      </div>
  </div>
  <script src="js/jspdf.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
  <script src="js/echarts.min.js"></script>
  <script src="js/Dcharts.js"></script>
  <script>
    let d = "";
    const vue = new Vue({
      el: '#app',
      data: {
      obj:{
        product:{
            'Milk Tea':{
                '2012':86.5,
                '2013':92.1,
                '2014':85.7,
                '2015':8
            },
            'Matcha Latte':{
                '2012':41.1,
                '2013':30.4,
                '2014':65.1,
                '2015':53.3
            },
            'Cheese Cocoa':{
                '2012':21.1,
                '2013':34.4,
                '2014':90.1,
                '2015':50.3
            },
            'Walnut Brownie':{
                '2012':91.1,
                '2013':34.4,
                '2014':50.1,
                '2015':20.3
            },
        }
      }
      },
      mounted() {
        d = new Dcharts();
        try {
          d.drawLayout("main", this.obj,"头部数据")
        } catch (error) {
          console.log(error);
        }
       
      },
    //   http://127.0.0.1:5500/Demo1.html?data={%22f1%22:[{%222012%22:%22222%22},{%222013%22:%22123%22},{%222014%22:%22100%22}],%22f2%22:[{%222012%22:%22111%22},{%222013%22:%2289%22},{%222014%22:%2290%22}],%22f3%22:[{%222012%22:%22333%22},{%222013%22:%2244%22},{%222014%22:%2222%22}]}
      methods:{
          getUrldata(name){
            return utils.getUrldata(name)
          },
          downloadPdf(){
                // let doc = new jsPDF('l', 'px', 'a4');
                // // let picBase64Info = d.getDataURL()
                // let echarts = document.querySelector("canvas")
                // console.log(echarts.offsetWidth);
                // console.log(doc);
                // let dataurl = echarts.toDataURL()
                // doc.addImage(dataurl,'PNG',100,100)
                // doc.save('Test.pdf');
                window.print()
          },
          close(){
            　 window.location.href="about:blank";
              window.close();
          }
      }
    });
  </script>
</body>

</html>